What the 3D view costs the console, why a 3D game is happy at 30 frames a second, and what makes it faster.
The console shows 60 pictures a second. A game finishes its work for a frame, then waits for the next refresh. If the work takes less than one refresh (16.7 milliseconds), the game runs at 60 frames a second. If it takes more than one but less than two, it simply waits for the second refresh and runs at 30 frames a second, perfectly steady. Only work that takes more than two refreshes drops lower.
30 frames a second is fine for a 3D game. It is what 3D games ran at on this kind of console, and a steady 30 looks and plays better than a 60 that sometimes slips to 45.
Measured on a release build of a room 24 by 24 tiles, with the view alone (nothing else drawing), as a share of one 60 frames a second refresh:
| What the camera is doing | Average | Worst frame | Frames over one refresh |
|---|---|---|---|
| Turning in the middle of the room | 59% | 77% | 0% |
| Walking and turning, bumping into walls | 64% | 112% | 6% |
| Standing 1.5 tiles from a wall (the most rows to draw) | 92% | 95% | 0% |
So the view by itself fits in a 60 frames a second refresh, and the rest of the game (your objects, a HUD, sounds) has what is left, with the whole second refresh as a cushion: a frame that takes up to twice as long still runs a steady 30.
Seven things (enemies, items) added to the same room, drawn every frame:
| What is going on | Average | Worst frame | Frames over one refresh |
|---|---|---|---|
| 7 things 3 to 5 tiles away, camera turning | 78% | 111% | 9% |
| 7 things, walking and turning | 70% | 82% | 0% |
| 7 big things 1.5 to 2 tiles away, camera turning | 85% | 118% | 12% |
| 7 big things, camera 1.5 tiles from a wall | 80% | 83% | 0% |
A thing costs only the pixels it covers, and only in the screen columns where no wall is in front of it, so a thing far away costs almost nothing and a thing right in front of the camera costs the most. Seven big things close up are still well inside the two refreshes a steady 30 frames a second allows (the worst frame was 118% of one refresh), so there is room for the rest of the game. The view draws at most 24 things a frame.
Most of the time is spent writing the picture: 120 columns by 160 rows of 2-pixel-wide dots, about 19,000 writes. A wall that is close covers many rows, so a close wall costs more than a far one. The floor and ceiling cost almost nothing: the console only repaints the part of a column that was a wall last time and is not now.
view3d_height draws fewer rows. A view 128 rows tall (leaving 32 for a HUD) draws a fifth fewer.The build does the rest ahead of time: it cuts the wall pictures into columns, and works out the tables for angles, distances and heights, so the console never calculates them while the game runs.